package org.fanximall.erp.product.infrastructure.repository;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import org.fanximall.erp.product.domain.repository.DictRepository;
import org.fanximall.erp.product.infrastructure.dao.entity.ProductConfDictDO;
import org.fanximall.erp.product.infrastructure.dao.mapper.ProductConfDictMapper;
import org.springframework.stereotype.Repository;

import javax.annotation.Resource;

/**
 * @author :  william
 * @version :  V1.0  created in 2024/4/23
 */
@Repository
public class DictRepositoryImpl implements DictRepository {

    @Resource
    private ProductConfDictMapper confDictMapper;

    @Override
    public String getDictName(String dictCode) {
        ProductConfDictDO confDict = confDictMapper.selectOne(new LambdaQueryWrapper<ProductConfDictDO>().select(
                ProductConfDictDO::getName)
                .eq(ProductConfDictDO::getCode, dictCode));
        return null == confDict ? null : confDict.getName();
    }
}
